package com.jiyinit.web.core.activiti.dao;

import com.jiyinit.core.framework.base.paging.PagingResult;
import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.core.framework.dao.mybatis.paginator.domain.PageBounds;
import com.jiyinit.web.core.activiti.dto.TabUserMemershipRequest;
import com.jiyinit.web.core.activiti.entity.TabUserMemershipEntity;
import com.jiyinit.web.core.common.util.Map2Bean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("core.tabUserMemershipDao")
public class TabUserMemershipDao {

    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(TabUserMemershipDao.class);

    private String SQLID = "core.tabUserMemershipDao.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;

    public int deleteByPrimaryKey(Integer id)
    {
        Map keyMap=new HashMap<>();
        keyMap.put("id",id);
        return mybatisDaoContext.delete(SQLID+"deleteByPrimaryKey",keyMap);
    }


    public int insert(TabUserMemershipEntity record)
    {
        return mybatisDaoContext.save(SQLID+"insert",record);
    }


    public int insertSelective(TabUserMemershipEntity record)
    {
        return mybatisDaoContext.save(SQLID+"insertSelective",record);
    }

    public TabUserMemershipEntity selectByPrimaryKey(Integer id)
    {
        Map keyMap=new HashMap<>();
        keyMap.put("id",id);
        return mybatisDaoContext.findOne(SQLID+"selectByPrimaryKey",TabUserMemershipEntity.class,keyMap);
    }

    public List<TabUserMemershipEntity> findBySelective(TabUserMemershipEntity record)
    {
        Map<String, Object> map= Map2Bean.beanToMap(record);
        return mybatisDaoContext.findAll(SQLID+"findBySelective",TabUserMemershipEntity.class,map);
    }

    public int updateByPrimaryKeySelective(TabUserMemershipEntity record)
    {
        return mybatisDaoContext.update(SQLID+"updateByPrimaryKeySelective",record);
    }

    public int updateByPrimaryKey(TabUserMemershipEntity record)
    {
        return mybatisDaoContext.update(SQLID+"updateByPrimaryKey",record);
    }

    public PagingResult<TabUserMemershipRequest> getListForPage(TabUserMemershipRequest request){
        PageBounds pageBounds = new PageBounds();
        pageBounds.setLimit(request.getLimit());
        pageBounds.setPage(request.getPage());
        return mybatisDaoContext.findForPage(SQLID + "getListForPage", TabUserMemershipRequest.class, request, pageBounds);
    }

    public int deleteByIds(Integer[] ids){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("ids", ids);
        return mybatisDaoContext.update(SQLID + "deleteByIds", map);
    }
}